package com.honey.comment.grammer.colon;

import java.util.regex.Matcher;

/**
 * 获取枚举字段
 * @author Administrator
 * 
 */
public class MatchEnumValue implements MatchItem{
	
	/** 枚举值 */
	private String enumValue = null;
	
	/** 枚举属性名称 */
	private String enumField = null;
	
	/** 枚举注释 */
	private String enumFieldComment = null;
	
	@Override
	public boolean match(String item ){
		boolean answer =false ; 
		Matcher matcher = PATTERN_COLON.matcher(item);
		int start = 0;
		
		String tmp = null;
		while( matcher.find() ){
			tmp = item.substring(start, matcher.start() ) ;
			start = matcher.end();
			if(tmp.length()>0 ){
				if(enumValue ==  null ){
					enumValue = tmp;
				}else if( enumField == null ){
					
					enumField = tmp;
					answer = true ;
				}else if( enumFieldComment == null ){
					enumFieldComment = tmp;
					break;
				}
			}
		}
		int size = item.length();
		if(start<size && answer){
			enumFieldComment = item.substring(start, size) ;
		}
		return answer;
	}
	
	@Override
	public String getValue() {
		return null;
	}

	/**
	 * @return the enumValue
	 */
	public final String getEnumValue() {
		return enumValue;
	}

	/**
	 * @return the enumField
	 */
	public final String getEnumField() {
		return enumField;
	}

	/**
	 * @return the enumFieldComment
	 */
	public final String getEnumFieldComment() {
		return enumFieldComment;
	}
}
